package cn.yx.common.core.exception;

import java.util.Arrays;

/**
 * <p>自定义的基础异常类，可带消息参数</p>
 *
 * @author Wgssmart
 */
public class BaseException extends RuntimeException {

    /**
     * 消息可带参数，如 缺少请求头{0} ，最终可通过messageParams解析成 缺少请求头Transaction-Id
     */
    private String[] messageParams;

    public BaseException() {
        super();
    }

    public BaseException(String message) {
        super(message);
    }

    public BaseException(String message, String[] messageParams) {
        super(message);
        this.messageParams = Arrays.copyOf(messageParams, messageParams.length);
    }

    public BaseException(String message, Throwable cause) {
        super(message, cause);
    }

    public BaseException(String message, String[] messageParams, Throwable cause) {
        super(message, cause);
        this.messageParams = Arrays.copyOf(messageParams, messageParams.length);
    }

    public BaseException(Throwable cause) {
        super(cause);
    }

    protected BaseException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
        super(message, cause, enableSuppression, writableStackTrace);
    }

    protected BaseException(String message, String[] messageParams, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
        super(message, cause, enableSuppression, writableStackTrace);
        this.messageParams = Arrays.copyOf(messageParams, messageParams.length);
    }

    public String[] getMessageParams() {
        return messageParams;
    }
}
